package com.grape.pojo;


import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

@Entity
@Table(name = "T_BOOKMARK_BOX")
public class Bookmark_Box implements Serializable{
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "BB_ID")	
	@GeneratedValue(strategy=GenerationType.AUTO)  
	private Integer id;
	
	@Column(name = "BB_NAME")
	private String bbname;
	
	
	
	@OneToMany(fetch = FetchType.LAZY, // 取消延迟加载
			targetEntity = Bookmark.class, // 目标对象
			orphanRemoval = true, // 孤儿删除
			mappedBy="bookmark_box") // 多方维护外键
	@OrderBy()
	private List<Bookmark> bs = new ArrayList<>();
	
	
	// cascade = CascadeType.ALL留着这个会把所有书签盒子都干掉
	@ManyToOne()
	@JoinColumn(name = "U_ID")
	private User user;

	@Override
	public String toString() {
		return "Bookmark_Box [id=" + id + ", bbname=" + bbname + ", bs=" + bs + "]";
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getBbname() {
		return bbname;
	}

	public void setBbname(String bbname) {
		this.bbname = bbname;
	}

	public List<Bookmark> getBs() {
		return bs;
	}

	public void setBs(List<Bookmark> bs) {
		this.bs = bs;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public Bookmark_Box(Integer id, String bbname, List<Bookmark> bs, User user) {
		super();
		this.id = id;
		this.bbname = bbname;
		this.bs = bs;
		this.user = user;
	}
	
	
	public Bookmark_Box(String bbname,List<Bookmark> bs, User user) {
		super();
		this.bbname = bbname;
		this.bs = bs;
		this.user = user;
	}
	
	public Bookmark_Box(String bbname, User user) {
		super();
		this.bbname = bbname;
		this.user = user;
	}
	
	
	public Bookmark_Box() {
		// TODO Auto-generated constructor stub
	}

	
}
